home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_3a.arc / DOTS.CPP < prev    next >
C/C++ Source or Header  |  1989-02-22  |  1KB  |  54 lines

  1. // dots.cpp    draw dots on the display with mouse.  button 1 (left)
  2. //        puts dots on, and buttons 2&3 (middle/right, right)
  3. //        take dots off.
  4. //
  5. // (c) Aspen Scientific 1989.  All Rights Reserved.
  6. // author: Vaughn Vernon
  7.  
  8. #include "point.cls"
  9. #include "display.cls"
  10. #include "mouse.cls"
  11. #include "keyboard.cls"
  12.  
  13. int
  14. main()
  15. {
  16.     Mouse mouse;
  17.     Display display(&mouse);
  18.     Keyboard kb;
  19.     KeyTypes ktype;
  20.     DisplayAttr attr;
  21.  
  22.     if (display.hasColor())
  23.         attr.set( attr.foreWhite() | attr.backBlue() );
  24.     else
  25.         attr.set( attr.reverse() );
  26.  
  27.     display.putString(Point(0, 0), " Press [Esc] to quit. ", attr);
  28.  
  29.     if (display.hasColor())
  30.         attr.set( attr.foreYellow() | attr.backBlack() );
  31.     else
  32.         attr.set( attr.normal() );
  33.  
  34.     display.cursorOff();
  35.  
  36.     Point mpoint;
  37.     unsigned b1, b2, b3;
  38.  
  39.     while( 1 ) {
  40.         if (mouse.getEvent(mpoint, b1, b2, b3) != 0) {
  41.             if (b1)
  42.                 display.putChar(mpoint, '.', attr);
  43.             else if (b2 || b3)
  44.                 display.putChar(mpoint, ' ', attr);
  45.  
  46.             display.draw();
  47.         }
  48.         else if (kb.input(0) == ktype.Escape())
  49.             break;
  50.     }
  51.  
  52.     display.cursorOn();
  53. }
  54.